/**
 * 您的公司.com
 * Copyright (c) 2018-2019 All Rights Reserved.
 */
package com.mei.demo.domain;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.List;

/**
 * 
 *
 * @author mei.xiaoliang@qq.com
 */
public class Test {

    public static void main(String[] args) {

        try {

            // 1.从Properties中获取值 反射进行,加载类
            Class<?> clazz = Class.forName("com.mei.demo.domain.City");
            Object c = clazz.getClass();
            //            City city = (City) clazz.newInstance();
            //            System.out.println("city: " + city);
            //
            //            // 2.解析类
            //            Collection collections = (Collection) clazz.newInstance();
            //            System.out.println(collections);

            int[] intArray = (int[]) Array.newInstance(int.class, 3);
            Integer[] intArray2 = (Integer[]) Array.newInstance(Integer.class, 3);
            City[] intArray3 = (City[]) Array.newInstance(clazz, 3);
            List<City> stringB = Arrays.asList(intArray3);

            Array.set(intArray, 0, 123);
            Array.set(intArray, 1, 456);
            Array.set(intArray, 2, 789);

            System.out.println("intArray[0] = " + Array.get(intArray, 0));
            System.out.println("intArray[1] = " + Array.get(intArray, 1));
            System.out.println("intArray[2] = " + Array.get(intArray, 2));

            System.out.println("list3: " + Arrays.toString(intArray3));
            System.out.println("list4: " + stringB);

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}
